cd "/Users/dlk265/Library/CloudStorage/Box-Box/Atkinson Projects/CKF volume/Revisions/Conclusion/"

use "anes_timeseries_cdf_stata_20220916.dta", clear

gen isolationist = VCF0823
recode isolationist (0=.) (2=0) (9=.)
gen gop3 = VCF0301
recode gop3(0=.) (1=0) (2=0) (3=0) (4=0) (5=0) (6=1) (7=1) 
gen gop5 = VCF0301
recode gop5(0=.) (1=0) (2=0) (3=0) (4=0) (5=1) (6=1) (7=1) 
gen dem3 = VCF0301
recode dem3(0=.) (1=1) (2=1) (3=0) (4=0) (5=0) (6=0) (7=0) 
gen dem5 = VCF0301
recode dem5(0=.) (1=1) (2=1) (3=1) (4=0) (5=0) (6=0) (7=0) 

gen female = VCF0104
recode female (0=.) (1=0) (2=1) (3=.)
gen age = VCF0101 
recode age (0=.)
gen white = 0
gen black = 0
gen hispanic = 0
replace white = 1 if VCF0105a == 1
replace black = 1 if VCF0105a == 2
replace hispanic = 1 if VCF0105a == 5
gen education = VCF0140a
recode education (9=.)

gen year = VCF0004

* Figure 1 *
logit isolationist gop5##i.year dem5##i.year education age white black hispanic female
margins year, at(dem5=1)
marginsplot, recast(scatter) xlabel(,angle(90)) ti("Democrats") yti("Isolationist" " ")  xti("") graphregion(color(white)) saving(dem5.gph, replace) plotopts(mcolor(black)) ciopts(lcolor(black))
margins year, at(gop5=1)
marginsplot, recast(scatter) xlabel(,angle(90)) ti("Republicans") yti("Isolationist" " ")  xti("") graphregion(color(white)) saving(gop5.gph, replace) plotopts(mcolor(black)) ciopts(lcolor(black))
margins year, at(gop5=0 dem5=0)
marginsplot, recast(scatter) xlabel(,angle(90)) ti("Independents") yti("Isolationist" " ") xti("") graphregion(color(white)) saving(ind5.gph, replace) plotopts(mcolor(black)) ciopts(lcolor(black))
graph combine gop5.gph dem5.gph ind5.gph, rows(3) graphregion(color(white)) xsize(8.5) ysize(11)

* Figure 2 *
gen defense_spend = VCF0843
recode defense_spend (0=.) (9=.)
gen cut_defense = defense_spend
recode cut_defense (2=1) (3=1) (4=0) (5=0) (6=0) (7=0)
logit cut_defense gop5##i.year dem5##i.year education age white black hispanic female 
margins year, at(gop5=1)
marginsplot, recast(scatter) xlabel(,angle(90)) ti("Republicans") graphregion(color(white)) saving(gop_cut.gph, replace) yti("Prob. support" " ") xti("") ylabel(0 .1 .2 .3 .4 .5 .6) plotopts(mcolor(black)) ciopts(lcolor(black))
margins year, at(dem5=1)
marginsplot, recast(scatter) xlabel(,angle(90)) ti("Democrats") graphregion(color(white)) saving(dem_cut.gph, replace) yti("Prob. support" " ") xti("") ylabel(0 .1 .2 .3 .4 .5 .6) plotopts(mcolor(black)) ciopts(lcolor(black))
*graph combine gop_cut.gph dem_cut.gph, graphregion(color(white)) rows(2) xsize(8.5) ysize(11)
margins year, at(gop5=0 dem5=0)
marginsplot, recast(scatter) xlabel(,angle(90)) ti("Independents") graphregion(color(white)) saving(ind_cut.gph, replace) yti("Prob. support" " ") xti("") ylabel(0 .1 .2 .3 .4 .5 .6) plotopts(mcolor(black)) ciopts(lcolor(black))
graph combine gop_cut.gph dem_cut.gph ind_cut.gph, graphregion(color(white)) rows(3) xsize(8.5) ysize(11)
